#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char str[1000];
    int key, i;
    while (scanf("%s%d", str, &key) == 2)
    {
        for (i = 0; str[i] != '\0'; i++)
        {
            int t = str[i] + key % 26 + (i + 1) % 26;
            while (t > 'Z')
                t -= 26;
            str[i] = t;
        }
        printf("%s %d\n", str, key);
    }
    return 0;
}
